# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Luca Weiss <luca@z3ntu.xyz>
pkgname=lomiri
pkgver=0.2.1
pkgrel=1
pkgdesc="A convergent desktop environment"
# armhf: blocked by lomiri-ui-toolkit
# s390x, riscv64, ppc64le: blocked by lomiri-system-settings
arch="all !armhf !s390x !riscv64 !ppc64le"
url="https://gitlab.com/ubports/development/core/lomiri"
license="GPL-3.0-only AND LGPL-2.1-only"
depends="
	ayatana-indicator-keyboard
	ayatana-indicator-session
	biometryd
	gsettings-desktop-schemas
	lomiri-notifications
	lomiri-schemas
	lomiri-settings-components
	lomiri-telephony-service
	lomiri-thumbnailer
	openrc-settingsd
	qt5-qtbase-sqlite
	qt5-qtgraphicaleffects
	suru-icon-theme
	"
makedepends="
	cmake
	cmake-extras
	dbus-test-runner
	doxygen
	elogind-dev
	geonames-dev
	gnome-desktop-dev
	graphviz
	gsettings-qt-dev
	libqtdbusmock
	libqtdbustest
	linux-pam-dev
	lomiri-api-dev
	lomiri-app-launch-dev
	lomiri-deviceinfo-dev
	lomiri-download-manager-dev
	lomiri-indicator-network-dev
	lomiri-libusermetrics-dev
	lomiri-system-settings
	lomiri-ui-toolkit-dev
	qmenumodel
	qmenumodel-dev
	qt5-qtbase-dev
	qt5-qtdeclarative-dev
	qtmir-dev
	samurai
	"
checkdepends="py3-dbusmock"
source="https://gitlab.com/ubports/development/core/lomiri/-/archive/$pkgver/lomiri-$pkgver.tar.gz
	0001-Fix-overwriting-INCLUDE_DIRECTORIES-variable.patch
	0002-Fix-build-on-32bit-arches-with-64bit-time_t.patch
	0003-cursor-Always-follow-cursor-position-from-mir.patch
	0004-Disable-broken-tests-due-to-dropped-mocks-from-mir-2.patch
	0005-Add-qt5-suffix-to-search-for-Qt-tools.patch
	0006-No-systemd.patch
	0007-Disable-lightdm-integration.patch
	0008-Change-hard-coded-launcher-logo-to-one-set-by-a-reso.patch
	home.svg
	"
subpackages="$pkgname-lang"
options="!check" # Tests fail

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_INSTALL_LOCALSTATEDIR=/var \
		-DBUILD_SHARED_LIBS=ON \
		-DCMAKE_BUILD_TYPE=None
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	# Replace the Ubuntu logo with Alpine
	rm "$pkgdir"/usr/share/lomiri/Launcher/graphics/home.svg
	install -Dm644 "$srcdir"/home.svg \
		"$pkgdir"/usr/share/lomiri/Launcher/graphics/

	# Remove various mocks and test files not wanted at runtime
	rm "$pkgdir"/usr/bin/indicators-client
	rm "$pkgdir"/usr/bin/lomiri-mock-indicator-service
	rm -r "$pkgdir"/usr/lib/lomiri/qml/mocks/
	rm -r "$pkgdir"/usr/lib/lomiri/qml/utils/Lomiri/SelfTest/
	rm -r "$pkgdir"/usr/libexec/lomiri/tests/
	rm "$pkgdir"/usr/libexec/lomiri/uqmlscene
	rm "$pkgdir"/usr/share/applications/indicators-client.desktop
	rm -r "$pkgdir"/usr/share/lomiri/mocks/
	rm -r "$pkgdir"/usr/share/lomiri/tests/
}

sha512sums="
4f844cb7552a6df9c3ed31f6705d0af2147fd44e7b390e8a4f7c5f95e61fc91590ebec1b296cf9eae83bbaa56df8fc5b1fa685143a788472e21525532d0b4251  lomiri-0.2.1.tar.gz
46f11652b0ed77fd27f14cef236a9f247885cc2fd85c433b47c617c0a9a3f80c292ba98c779b02e75bd752075160dc5e997b3f2bd4e24ee7f7005706268ded81  0001-Fix-overwriting-INCLUDE_DIRECTORIES-variable.patch
2a1f8069ff84486f7905fa2dc098b283c4d8308ad374d3f8383559241bfd9da4cabaecacfef41825f154e0d2d902eb85dff788aaca6260e1f6a21714bba7ff1d  0002-Fix-build-on-32bit-arches-with-64bit-time_t.patch
f124a98e8b13a0c640ab7180a9516d11122c787bff821225f7730fe292ad476a7fc68d1ffa7b3d2be0f3daf4732c3d60aba61044225764bf62eb4b432ca51a68  0003-cursor-Always-follow-cursor-position-from-mir.patch
1ce136ed0dd5f9a285d194684194ca04135ad9b4a7ac3bea5f1714b58465cc8d98f5f218938ea2155d9d9a4939877a65b7f7b02dba2d6beed3a940e42e137fd8  0004-Disable-broken-tests-due-to-dropped-mocks-from-mir-2.patch
33e92a4646352f16993829ae7686b7ebf2c949d418e51ed466268b53d8d0f939861fa113a19403936ce48e16e58c6166e370a4fd27a184bde554c4e2746b0898  0005-Add-qt5-suffix-to-search-for-Qt-tools.patch
828c19e69cc830b40d648ed5bfe03fdd350986c0f6276c7cb659097c54bb593a5a5c2471d2b4a463ced80f23f790829f50f5ec807c4e0d846e5b84a433109c1c  0006-No-systemd.patch
1ddd7a73bf5aa815e50251afd4b54563cc366667c9b9d230ba377451a569a0af01255ad2a3dbff255fc2067d9a404592f3c3f3910ff1c1a83f1280741663e92d  0007-Disable-lightdm-integration.patch
c953baa7ee424567105dcf37f45674638f9b8236e59121e05f454ccf198d65a9f8de445cfcc3d78a6e11439e395c33812d161b8fff0a6e03df2ee3f4d5526fbd  0008-Change-hard-coded-launcher-logo-to-one-set-by-a-reso.patch
8be30a5e7692c39ffb1948910b45d8fa69a88725df45b67ba69711281b3cf15568b9fff29a8b5b216e5e86656b5961ad7ef9eb0e87c007215e012c3a663045b7  home.svg
"
